#include <bits/stdc++.h>
#define int long long
using namespace std;
int cnt=0;
struct acar {
    int d; int v; int a;
}p[100005];
struct node {
    int l; int r;
}fspeed[100005];
int seespeed[1000005];
int checkspeed[100005];
int minright[1000005];
signed main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T; scanf("%lld",&T);
    for(int te=1;te<=T;++te) {
        cnt=0;
        for(int i=0;i<=1000001;++i) {
            minright[i]=INT_MAX;
            seespeed[i]=0;
        }
        int n,m,L,V;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(int i=1;i<=n;++i)
            scanf("%lld%lld%lld",&p[i].d,&p[i].v,&p[i].a);
        for(int i=1;i<=m;++i) {
            scanf("%lld",&checkspeed[i]);
            ++seespeed[checkspeed[i]];
        }
        for(int i=1;i<=L;++i)
            seespeed[i]+=seespeed[i-1];
        for(int i=1;i<=n;++i) {
            if(p[i].a>=0) {
                int ret=0;
                if(p[i].v>V) ret=p[i].d;
                else {
                    if(p[i].a!=0) ret=p[i].d+(V*V-p[i].v*p[i].v+2*p[i].a)/(2*p[i].a);
                    else ret=L+1;
                }
                if(ret>L) ret=L+1;
                int hasin=seespeed[L];
                if(ret) hasin-=seespeed[ret-1];
                if(ret!=L+1 && hasin) {
                    ++cnt;
                    fspeed[cnt].l=ret;
                    fspeed[cnt].r=L;
                }
            }
            if(p[i].a<0 && p[i].v>V) {
                int l=p[i].d-1,r=L+1,mid,ret=L+1;
                while(l+1<r) {
                    mid=(l+r) >> 1;
                    if(p[i].v*p[i].v+2*p[i].a*(mid-p[i].d)<=V*V) {
                        r=mid;
                        ret=mid;
                    }
                    else l=mid;
                }
                if(ret>L) ret=L+1;
                int hasin=seespeed[ret-1];
                if(ret) hasin-=seespeed[p[i].d-1];
                if(hasin) {
                    ++cnt;
                    fspeed[cnt].l=p[i].d;
                    fspeed[cnt].r=ret-1;
                }
            }
        }
        for(int i=1;i<=cnt;++i)
            minright[fspeed[i].l]=min(minright[fspeed[i].l],fspeed[i].r);
        for(int i=L;i>=0;--i)
            minright[i]=min(minright[i+1],minright[i]);
        int point=0; int ans=0;
        while(minright[checkspeed[point]+1]!=INT_MAX) {
            int lstp=point;
            while(checkspeed[point+1]<=minright[checkspeed[lstp]+1] && point+1<=m) ++point;
            ++ans;
        }
        printf("%lld %lld\n",cnt,m-ans);
    }
    return 0;
}
